﻿@page "/daily/expenditure";
@namespace YwhWeb.Pages.Daily

<div style="text-align: right;">
    <PageContainer Title="财务收支">
        <Content>   
            <Button @onclick="_=>NewDrawer()">添加记录</Button> 
            
            </Content>

        
            <ChildContent>
            <Table @ref="table"
                   TItem="YwhLib.Expenditure"
                   DataSource="@expenditureRsp.Items"
                   Total="_total"
                   @bind-PageIndex="_pageIndex"
                   @bind-PageSize="_pageSize"
                   @bind-SelectedRows="selectedRows"
                   OnChange="OnChange">
                <Selection Key="@(context.ExpenditureId.ToString())" />
                <AntDesign.Column Title="记录id" @bind-Field="@context.ExpenditureId" Sortable />
                <AntDesign.Column Title="收支类型" @bind-Field="@context.IsIncome" Sortable >
                    @if(context.IsIncome)
                    {
                        <Text>收入</text>
                    }
                    else
                    {
                        <Text>支出</text>
                    }
                </AntDesign.Column >
                <AntDesign.Column Title="金额" @bind-Field="@context.Amount" />
                <AntDesign.Column Title="添加时间" @bind-Field="@context.AddTime" Format="yyyy-MM-dd" Sortable />
                <AntDesign.Column Title="发生时刻" @bind-Field="@context.Point" Format="HH:mm:ss"/>
                <AntDesign.Column Title="人员" @bind-Field="@context.Person" />
                <AntDesign.Column Title="描述" @bind-Field="@context.Description" />
            </Table>
            </ChildContent>
    </PageContainer>
</div>

<Drawer Visible="this.drawerVisible" Width="500" OnClose="a=>{this.drawerVisible=false;}">
    <Title Level="4">收支记录</Title>
    <div>
    <p ></p>
 </div>

 <Text>收支类型:</Text>
<div>
    <RadioGroup @bind-Value="@editExpenditure.IsIncome" >
        <Radio Value="true">收入</Radio>
        <Radio Value="false">支出</Radio>
    </RadioGroup>
</div>
<p></p>

<Text>金额:</Text>
<div>
    <Input Placeholder="请输入金额" @bind-Value="@editExpenditure.Amount"  />
    <p></p>
</div>

<Text>添加时间:</Text>
    <div>
    <DatePicker TValue="DateTime" ShowTime="@true"
               DefaultValue=@editExpenditure.AddTime
               Format="yyyy-MM-dd"
               DisabledDate="date => date <= DateTime.Now"
               DisabledTime="date => GetDisabledTime(date)" 
               />
    <p></p>
</div>

<Text>发生时刻:</Text>
    <div>
    <DatePicker TValue="DateTime" ShowTime="@true"
               DefaultValue=@editExpenditure.Point
               Format="HH:mm:ss"
               DisabledDate="date => date <= DateTime.Now"
               DisabledTime="date => GetDisabledTime(date)" 
               />
    <p></p>
</div>

  <Text>人员:</Text>
    <div>
    <AutoComplete @bind-Value="@editExpenditure.Person" Options="@options" OnSelectionChange="OnSelectionChange"  Placeholder=""/>
    <p></p>
</div>

<Text>描述:</Text>
<TextArea Rows="4" Placeholder="请输入收支细节原因" @bind-Value="@editExpenditure.Description"/>
<p></p>
  
<div style="text-align: right;">
    <Button Type="@ButtonType.Primary">保存</Button>
</div>
</Drawer>
